using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using QuanLyKhachSan.BUS;
using QuanLyKhachSan.DTO;

namespace QuanLyKhachSan.DAO
{
    public class PhieuThuePhongDAO
    {
        public static bool Insert(PhieuThuePhongDTO phieuThuedto)
        {
            int kq = 0;
            DataAccessHelper con = new SqlDataAccessHelper();
            string sql = "INSERT INTO PhieuThuePhong (maPhong,ngayThue,heSoThue,phuThuThue,donGiaThue) VALUES (" + phieuThuedto.MaPhong + ",'" + phieuThuedto.NgayThue.ToString() + "'," + phieuThuedto.HeSoThue + "," + phieuThuedto.PhuThuThue + "," + phieuThuedto.DonGiaThue + ")";
            kq = con.ExecuteNonQuery1(sql);
            if (kq > 0)
            {
                return true;
            }
            return false;
        }
        public static DataTable LayDSPhieuThue()
        {
            DataTable dt = new DataTable();
            return dt;
        }
        public static DataTable LayMaPhieuThueTheoMaPhong(int maPhong)
        {
            DataTable dt = new DataTable();
            DataAccessHelper con = new SqlDataAccessHelper();
            string sql = "SELECT MAX(maPhieuThue) FROM PhieuThuePhong pt,Phong p WHERE pt.maPhong=p.maPhong and p.maPhong=" + maPhong;
            dt = con.ExecuteQuery(sql);
            return dt;
        }
        public static DataTable LayMaPhieuThueMoiThem()
        {
            DataTable dt = new DataTable();
            DataAccessHelper con = new SqlDataAccessHelper();
            string sql = "SELECT * FROM PhieuThuePhong WHERE maPhieuThue=" + "(SELECT MAX(maPhieuThue) FROM PhieuThuePhong)";
            dt = con.ExecuteQuery(sql);
            return dt;
        }
    }
}
